class Effect extends Sprite{
    private ani: Animation;
    constructor() {
        super();
        this.ani = new Animation();
        this.width = 100;
        this.height = 100;
    }

    public play(resID:number,interval:number = 150):void{
        this.ani.loadAtlas("res/atlas/"+resID+".atlas"); // 加载图集动画
        this.ani.interval = interval; // 设置播放间隔（单位：毫秒）
        this.ani.index = 1; // 当前播放索引
        this.ani.play(); // 播放图集动画

        // 获取动画的边界信息
        var bounds: Rectangle = this.ani.getGraphicBounds();
        this.ani.pivot(bounds.width / 2, bounds.height / 2);
        this.ani.pos(this.width / 2, this.height/2);
        this.addChild(this.ani);
    }

    public stop():void{
        if(this.ani){
            this.ani.stop();
        }
    }
}